import redis


class RedisClient:
    def __init__(self, host='localhost', port=6379, db=0):
        self.client = redis.Redis(host=host, port=port, db=db)

    def get_value(self,  key):
        return self.client.get(key)
    def set_value(self, key, value):
        return self.client.set(key, value)
    def set_value_time(self,  key, value, timeout):
        return self.client.setex(key, timeout, value)
    #list数据类型
    def rpush(self,  key, value):
        self.client.rpush(key, value)

    def rpop(self, key):
        return self.client.rpop(key)
    def lrange(self, key, start, end):
        return self.client.lrange(key, start, end)
    def llen(self, key):
        return self.client.llen(key)
    def lrem(self, key, value):
        return self.client.lrem(key, value)
r = RedisClient()
# r.rpush('imaglist','1.jpg')
# r.rpush('imaglist','2.jpg')
# r.rpush('imaglist','3.jpg')
# r.rpush('imaglist','4.jpg')
#
# count = r.llen('imaglist')
# print(count)
# print(r.lrange('imaglist',0,3))

